correct [[deprecated]] attribute placement on class#3142
Conversation
…lass
The previous declaration placed the [[deprecated]] attribute between the class-key and the RCLCPP_PUBLIC visibility macro:
class RCLCPP_PUBLIC [[deprecated(\"...\")]] MemoryStrategy
This form fails to compile under GCC 11.2 because the parser cannot
correctly handle a C++ standard attribute followed by a GNU
__attribute__ (which RCLCPP_PUBLIC expands to on Linux) in the class
head, resulting in errors such as:
error: expected primary-expression before 'public'
error: expected '}' before 'public'
Move the [[deprecated]] attribute to the declaration position,
immediately before the class-key. This form is parsed reliably by
GCC, Clang, and MSVC, ensures the deprecation warning is actually
emitted at use sites, and also propagates to derived classes.
Signed-off-by: EricX-Zhao <ericzhao0325@163.com>
|
Pulls: #3142 |
jmachowinski
left a comment
There was a problem hiding this comment.
This removes the deprecation warning, as it is simply ignored.
I found no way to make it compile under GCC 12.1.
|
Closing, as the proposed patch is not working, and aiming at an unsupported platform (gcc 12.3 / ubuntu 22.04) |
fujitatomoya
left a comment
There was a problem hiding this comment.
standard says an attribute-specifier-seq appertaining to a class declaration should appear right after the class keyword or before the class keyword as part of the decl-specifier-seq. so i think this is a right thing to do.
|
my reply was cached in the browser, so ignore the previous comment. |
Description
The previous declaration placed the [[deprecated]] attribute between the class-key and the RCLCPP_PUBLIC visibility macro:
This form fails to compile under GCC 11.2 because the parser cannot correctly handle a C++ standard attribute followed by a GNU attribute (which RCLCPP_PUBLIC expands to on Linux) in the class head, resulting in errors such as:
Move the [[deprecated]] attribute to the declaration position, immediately before the class-key. This form is parsed reliably by GCC, Clang, and MSVC, ensures the deprecation warning is actually emitted at use sites, and also propagates to derived classes.
Is this user-facing behavior change?
No
Did you use Generative AI?
Yes Claude Code Opus4.6
Additional Information